var t = require("../../../@babel/runtime/helpers/toConsumableArray"), a = getApp();

Page({
    data: {
        goodsList: [],
        loading: !1,
        isMoreData: !0,
        page: 1,
        searchInputKeyword: "",
        searchGoodsList: null
    },
    onLoad: function() {
        this.getGoods(), wx.setNavigationBarTitle({
            title: "我的库存"
        });
    },
    onReachBottom: function() {
        this.getGoods();
    },
    onShareAppMessage: function() {},
    onShareTimeline: function() {},
    viewDetails: function(t) {
        var a = t.target.dataset.id;
        wx.navigateTo({
            url: "/packageH/stock/details/details?id=" + a
        });
    },
    getGoods: function() {
        var e = this;
        if (!this.data.loading && !1 !== this.data.isMoreData) {
            this.setData({
                loading: !0
            });
            var s = a.getNetAddresss("plugin.agency.api.stock.get-list");
            s += "&page=" + this.data.page, a._postNetWork({
                url: s,
                success: function(a) {
                    var s = a.data, i = s.data, o = s.result, n = s.msg;
                    if (0 === o) return wx.hideLoading(), void wx.showToast({
                        title: n,
                        success: function() {
                            wx.redirectTo({
                                url: "/packageG/member_v2/member_v2"
                            });
                        }
                    });
                    var r = {
                        loading: !1
                    };
                    (i.current_page === i.last_page || 0 === i.data.length || i.data.length < i.per_page) && (r.isMoreData = !1);
                    var d = e.data.goodsList;
                    d.push.apply(d, t(i.data)), r.goodsList = d, r.page = e.data.page + 1, e.setData(r), 
                    wx.hideLoading();
                }
            });
        }
    },
    searchGoods: function(t) {
        var a = t.detail, e = this.data.goodsList.filter(function(t) {
            return -1 !== t.title.indexOf(a);
        });
        this.setData({
            searchGoodsList: e,
            searchInputKeyword: a
        });
    },
    cancelSearch: function() {
        this.setData({
            searchGoodsList: null
        });
    }
});